package com.concurrent.sample.business.assemble;

import com.concurrent.sample.business.consts.enums.FlowTypeEnum;
import com.concurrent.sample.business.entity.EventEntity;
import com.concurrent.sample.business.entity.OrderEntity;
import com.concurrent.sample.business.consts.enums.EventTypeEnum;
import com.concurrent.sample.business.consts.enums.TargetStatusEnum;
import com.concurrent.sample.business.dto.request.CreateTradeEventRequest;
import org.springframework.stereotype.Component;

@Component
public class EventAssemble {

  public EventEntity buildEventEntity(CreateTradeEventRequest param){
    return new EventEntity()
        .setPositionId(param.getPositionId())
        .setCustomerNo(param.getCustomerNo())
        .setSymbol(param.getSymbol())
        .setEventType(EventTypeEnum.TRADE_SHORT)
        .setSide(param.getSide())
        .setQuantity(param.getQuantity())
        .setMemo(param.getMemo())
        .setTargetStatus(TargetStatusEnum.PROCEEDING)
        ;
  }

  public OrderEntity buildOrderEntity(EventEntity event){
    return new OrderEntity()
        .setPositionId(event.getPositionId())
        .setEventId(event.getId())
        .setCustomerNo(event.getCustomerNo())
        .setFlowStatus(FlowTypeEnum.COMMITTED)
        .setSymbol(event.getSymbol())
        .setSide(event.getSide())
        .setOrderQty(event.getQuantity())
        .setLeaveQty(event.getQuantity())
        ;
  }

}
